<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <script src="../js/jquery.min.js"></script>
    
</head>
<body>
    <script>
        console.log("--------数组的解构赋值---------");
        //基本用法
        let [x,y] = [1,2];
        console.log(x);//1
        console.log(y);//2

        //剩余运算符
        let a,b,rest;
        [a,b,...rest]=[1,2,3,4,5,6];
        console.log(a);//1
        console.log(b);//2
        console.log(rest);//[3,4,5,6]

        //可忽略
        let [c,,d] = [1,2,3];
        console.log(c,d);
        console.log(c);
        console.log(d);

        //不完全解构
        let [e,f] =[1];
        console.log(e,f);//1,undefined
        console.log(e);//1
        // consoel.log(f);//报错

        //解构默认值
        let[g, h = 6] = [7];

        console.log(g,h);
        console.log(g);
        console.log(h);

        //对字符串进行解构赋值
        let [i,l,j,k,m] ="hello";
        console.log(i);
        console.log(l);
        console.log(j);
        console.log(k);
        console.log(m);

        console.log("-----------解构赋值-交换两个变量的值-------------");
        var num1 = 10;
        var num2 = 20;
        console.log(num1,num2);

        [num1,num2] = [num2,num1];
        console.log(num1,num2);


    </script>
    
</body>
</html>